<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>05.vue中使用Velocity</title>
    <link rel="stylesheet" href="animate.css">
</head>
<style>
</style>
<body>
    <div id="app">
        <transition 
            name="fade"
            @before-enter="handleBeforeEnter"
            @enter="handleEnter"
            @after-enter="handleAfterEnter"
        >
            <div v-show="show">hello world</div>
        </transition>

        <button @click="handleClick">切换</button>
    </div>
</body>
<script src="vue.js"></script>
<script src="velocity.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            show: true
        },
        methods: {
            handleClick: function() {
                this.show = !this.show;
            },
            handleBeforeEnter: function(el) {
               el.style.opacity = 0;
            },
            handleEnter: function(el, done) {
                Velocity(el, {
                    opacity: 1
                },{
                    duration: 1000,
                    complete: done
                })
            },
            handleAfterEnter: function(el) {
                console.log('动画结束！')
            }
        }
    })
</script>
</html>